View Javadoc
1 /* 2 * Created by IntelliJ IDEA. 3 * User: birchfield 4 * Date: Aug 18, 2002 5 * Time: 8:13:01 PM 6 * To change template for new class use 7 * Code Style | Class Templates options (Tools | IDE Options). 8 */ 9 package net.plugin.sql.util; 10 11 import net.plugin.sql.beans.DataSource; 12 13 import java.sql.*; 14 15 public class JDBCConnectionManager { 16 17 private DataSource dataSource = null; 18 19 public JDBCConnectionManager(DataSource dataSource) { 20 this.dataSource = dataSource; 21 } 22 23 public Connection getConnection() throws DataSourceException { 24 try { 25 Class.forName(dataSource.getDriver()).newInstance(); 26 } catch (InstantiationException e) { 27 throw new DataSourceException("InstantiationException - " + e.getMessage()); 28 } catch (IllegalAccessException e) { 29 throw new DataSourceException("IllegalAccessException - " + e.getMessage()); 30 } catch (ClassNotFoundException e) { 31 throw new DataSourceException("ClassNotFoundException - " + e.getMessage()); 32 } 33 Connection conn; 34 try { 35 conn = DriverManager.getConnection(dataSource.getUrl(), dataSource.getUser(), dataSource.getPassword()); 36 } catch (SQLException e) { 37 throw new DataSourceException("SQLException - " + e.getMessage()); 38 } 39 return conn; 40 } 41 }

This page was automatically generated by Maven